package com.tarry.controller;

import com.tarry.bean.PageQuery;
import com.tarry.common.Result;
import com.tarry.model.vo.AclVo;
import com.tarry.service.SysAclService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/sys/acl")
@Slf4j
public class SysAclController {

    @Autowired
    private SysAclService sysAclService;
    //@Resource
    //private SysRoleService sysRoleService;

    @RequestMapping("/save.json")
    @ResponseBody
    public Result saveAclModule(AclVo param) {
        sysAclService.save(param);
        return Result.success();
    }

    @RequestMapping("/update.json")
    @ResponseBody
    public Result updateAclModule(AclVo param) {
        sysAclService.update(param);
        return Result.success();
    }

    @RequestMapping("/page.json")
    @ResponseBody
    public Result list(@RequestParam("aclModuleId") Integer aclModuleId, PageQuery pageQuery) {
        return Result.success(sysAclService.getPageByAclModuleId(aclModuleId, pageQuery));
    }

//    @RequestMapping("acls.json")
//    @ResponseBody
//    public Result acls(@RequestParam("aclId") int aclId) {
//        Map<String, Object> map = Maps.newHashMap();
//        List<SysRole> roleList = sysRoleService.getRoleListByAclId(aclId);
//        map.put("roles", roleList);
//        map.put("users", sysRoleService.getUserListByRoleList(roleList));
//        return Result.success(map);
//    }

}
